// JavaScript Document

<!-- Variable Declaration Area -->
var field_counter = 0;
var field_false_counter = 0;
<!-- Variable Declaration Area -->

function newAccountValidation(){
	var error = 0;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	//Validate the First name
	if(document.newaccount.fname.value == "" || document.newaccount.fname.value.charAt(0) == " "){
			document.newaccount.fname.style.background = "#f37474";
			document.newaccount.fname.style.color = "#fff";
			document.newaccount.fname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.newaccount.fname.style.background = "#ffffff";
			document.newaccount.fname.style.color = "#888D8F";
			document.newaccount.fname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	//Validate the last name
	if(document.newaccount.lname.value == "" || document.newaccount.lname.value.charAt(0) == " "){
			document.newaccount.lname.style.background = "#f37474";
			document.newaccount.lname.style.color = "#fff";
			document.newaccount.lname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.newaccount.lname.style.background = "#ffffff";
			document.newaccount.lname.style.color = "#888D8F";
			document.newaccount.lname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	//Validate the email
	if(document.newaccount.email.value.charAt(0) == " " || reg.test(document.newaccount.email.value) == false){
			document.newaccount.email.style.background = "#f37474";
			document.newaccount.email.style.color = "#fff";
			document.newaccount.email.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.newaccount.email.style.background = "#ffffff";
			document.newaccount.email.style.color = "#888D8F";
			document.newaccount.email.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function loginValidation(){
	var error = 0;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	//Validate the First name
	if(document.loginForm.username.value == "" || document.loginForm.username.value.charAt(0) == " "){
			document.loginForm.username.style.background = "#f37474";
			document.loginForm.username.style.color = "#fff";
			document.loginForm.username.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.loginForm.username.style.background = "#ffffff";
			document.loginForm.username.style.color = "#888D8F";
			document.loginForm.username.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	//Validate the First name
	if(document.loginForm.password.value == "" || document.loginForm.password.value.charAt(0) == " "){
			document.loginForm.password.style.background = "#f37474";
			document.loginForm.password.style.color = "#fff";
			document.loginForm.password.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.loginForm.password.style.background = "#ffffff";
			document.loginForm.password.style.color = "#888D8F";
			document.loginForm.password.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function recoverValidation(){
	var error = 0;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	//Validate the email
	if(document.recoverForm.email.value.charAt(0) == " " || reg.test(document.recoverForm.email.value) == false){
			document.recoverForm.email.style.background = "#f37474";
			document.recoverForm.email.style.color = "#fff";
			document.recoverForm.email.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.recoverForm.email.style.background = "#ffffff";
			document.recoverForm.email.style.color = "#888D8F";
			document.recoverForm.email.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function classCreateValidation(){
	var error = 0;

	//Validate the email
	if(document.createclass.name.value == "" || document.createclass.name.value.charAt(0) == " "){
			document.createclass.name.style.background = "#f37474";
			document.createclass.name.style.color = "#fff";
			document.createclass.name.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.createclass.name.style.background = "#ffffff";
			document.createclass.name.style.color = "#888D8F";
			document.createclass.name.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.createclass.description.value == "" || document.createclass.description.value == "Write a brief description of your course"){
			document.createclass.description.style.background = "#f37474";
			document.createclass.description.style.color = "#fff";
			document.createclass.description.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.createclass.description.style.background = "#ffffff";
			document.createclass.description.style.color = "#888D8F";
			document.createclass.description.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.createclass.course_goal.value == "" || document.createclass.course_goal.value == "What the user will learn with this course"){
			document.createclass.course_goal.style.background = "#f37474";
			document.createclass.course_goal.style.color = "#fff";
			document.createclass.course_goal.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.createclass.course_goal.style.background = "#ffffff";
			document.createclass.course_goal.style.color = "#888D8F";
			document.createclass.course_goal.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function homeworkValidation(){
	var error = 0;

	//Validate the email
	if(document.homeworkCreator.title.value == "" || document.homeworkCreator.title.value.charAt(0) == " "){
			document.homeworkCreator.title.style.background = "#f37474";
			document.homeworkCreator.title.style.color = "#fff";
			document.homeworkCreator.title.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.homeworkCreator.title.style.background = "#ffffff";
			document.homeworkCreator.title.style.color = "#888D8F";
			document.homeworkCreator.title.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.homeworkCreator.end_date.value == "" || document.homeworkCreator.end_date.value.charAt(0) == " "){
			document.homeworkCreator.end_date.style.background = "#f37474";
			document.homeworkCreator.end_date.style.color = "#fff";
			document.homeworkCreator.end_date.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.homeworkCreator.end_date.style.background = "#ffffff";
			document.homeworkCreator.end_date.style.color = "#888D8F";
			document.homeworkCreator.end_date.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.getElementById("uid").value == '0'){
			document.homeworkCreator.uid.style.background = "#f37474";
			document.homeworkCreator.uid.style.color = "#fff";
			document.homeworkCreator.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.homeworkCreator.uid.style.background = "#ffffff";
			document.homeworkCreator.uid.style.color = "#888D8F";
			document.homeworkCreator.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function homeworkEditValidation(){
	var error = 0;

	//Validate the email
	if(document.homeworkCreator.title.value == "" || document.homeworkCreator.title.value.charAt(0) == " "){
			document.homeworkCreator.title.style.background = "#f37474";
			document.homeworkCreator.title.style.color = "#fff";
			document.homeworkCreator.title.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.homeworkCreator.title.style.background = "#ffffff";
			document.homeworkCreator.title.style.color = "#888D8F";
			document.homeworkCreator.title.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.homeworkCreator.end_date.value == "" || document.homeworkCreator.end_date.value.charAt(0) == " "){
			document.homeworkCreator.end_date.style.background = "#f37474";
			document.homeworkCreator.end_date.style.color = "#fff";
			document.homeworkCreator.end_date.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.homeworkCreator.end_date.style.background = "#ffffff";
			document.homeworkCreator.end_date.style.color = "#888D8F";
			document.homeworkCreator.end_date.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function powerpointValidation(){
	var error = 0;

	//Validate the email
	if(document.powerpointform.title.value == "" || document.powerpointform.title.value.charAt(0) == " "){
			document.powerpointform.title.style.background = "#f37474";
			document.powerpointform.title.style.color = "#fff";
			document.powerpointform.title.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.powerpointform.title.style.background = "#ffffff";
			document.powerpointform.title.style.color = "#888D8F";
			document.powerpointform.title.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.powerpointform.pp_presentation.value == "" || document.powerpointform.pp_presentation.value.charAt(0) == " "){
			document.powerpointform.pp_presentation.style.background = "#f37474";
			document.powerpointform.pp_presentation.style.color = "#fff";
			document.powerpointform.pp_presentation.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.powerpointform.pp_presentation.style.background = "#ffffff";
			document.powerpointform.pp_presentation.style.color = "#888D8F";
			document.powerpointform.pp_presentation.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function videocontentValidation(){
	var error = 0;

	//Validate the email
	if(document.videocontent.title.value == "" || document.videocontent.title.value.charAt(0) == " "){
			document.videocontent.title.style.background = "#f37474";
			document.videocontent.title.style.color = "#fff";
			document.videocontent.title.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.videocontent.title.style.background = "#ffffff";
			document.videocontent.title.style.color = "#888D8F";
			document.videocontent.title.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.videocontent.video_url.value == "" || document.videocontent.video_url.value.charAt(0) == " "){
			document.videocontent.video_url.style.background = "#f37474";
			document.videocontent.video_url.style.color = "#fff";
			document.videocontent.video_url.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.videocontent.video_url.style.background = "#ffffff";
			document.videocontent.video_url.style.color = "#888D8F";
			document.videocontent.video_url.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.videocontent.video_description.value == "" || document.videocontent.video_description.value.charAt(0) == " "){
			document.videocontent.video_description.style.background = "#f37474";
			document.videocontent.video_description.style.color = "#fff";
			document.videocontent.video_description.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.videocontent.video_description.style.background = "#ffffff";
			document.videocontent.video_description.style.color = "#888D8F";
			document.videocontent.video_description.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function richtextValidation(){
	var error = 0;

	//Validate the email
	if(document.richtextcontent.title.value == "" || document.richtextcontent.title.value.charAt(0) == " "){
			document.richtextcontent.title.style.background = "#f37474";
			document.richtextcontent.title.style.color = "#fff";
			document.richtextcontent.title.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.richtextcontent.title.style.background = "#ffffff";
			document.richtextcontent.title.style.color = "#888D8F";
			document.richtextcontent.title.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function homeworkmoduleValidation(){
	var error = 0;

	//Validate the email
	if(document.homeworkmodule.title.value == "" || document.homeworkmodule.title.value.charAt(0) == " "){
			document.homeworkmodule.title.style.background = "#f37474";
			document.homeworkmodule.title.style.color = "#fff";
			document.homeworkmodule.title.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.homeworkmodule.title.style.background = "#ffffff";
			document.homeworkmodule.title.style.color = "#888D8F";
			document.homeworkmodule.title.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.homeworkmodule.end_date.value == "" || document.homeworkmodule.end_date.value.charAt(0) == " "){
			document.homeworkmodule.end_date.style.background = "#f37474";
			document.homeworkmodule.end_date.style.color = "#fff";
			document.homeworkmodule.end_date.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.homeworkmodule.end_date.style.background = "#ffffff";
			document.homeworkmodule.end_date.style.color = "#888D8F";
			document.homeworkmodule.end_date.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function setupexamValidation(){
	var error = 0;

	//Validate the email
	if(document.setupexam.start_date.value == "" || document.setupexam.start_date.value.charAt(0) == " "){
			document.setupexam.start_date.style.background = "#f37474";
			document.setupexam.start_date.style.color = "#fff";
			document.setupexam.start_date.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.setupexam.start_date.style.background = "#ffffff";
			document.setupexam.start_date.style.color = "#888D8F";
			document.setupexam.start_date.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.setupexam.end_date.value == "" || document.setupexam.end_date.value.charAt(0) == " "){
			document.setupexam.end_date.style.background = "#f37474";
			document.setupexam.end_date.style.color = "#fff";
			document.setupexam.end_date.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.setupexam.end_date.style.background = "#ffffff";
			document.setupexam.end_date.style.color = "#888D8F";
			document.setupexam.end_date.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function createEventValidation(){
	var error = 0;

	//Validate the email
	if(document.createevent.end_date.value == "" || document.createevent.end_date.value.charAt(0) == " "){
			document.createevent.end_date.style.background = "#f37474";
			document.createevent.end_date.style.color = "#fff";
			document.createevent.end_date.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.createevent.end_date.style.background = "#ffffff";
			document.createevent.end_date.style.color = "#888D8F";
			document.createevent.end_date.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.createevent.title.value == "" || document.createevent.title.value.charAt(0) == " "){
			document.createevent.title.style.background = "#f37474";
			document.createevent.title.style.color = "#fff";
			document.createevent.title.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.createevent.title.style.background = "#ffffff";
			document.createevent.title.style.color = "#888D8F";
			document.createevent.title.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function editEventValidation(data){
	var error = 0;
	
	//Validate the email
	if(data.end_date.value == "" || data.end_date.value.charAt(0) == " "){
			data.end_date.style.background = "#f37474";
			data.end_date.style.color = "#fff";
			data.end_date.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			data.end_date.style.background = "#ffffff";
			data.end_date.style.color = "#888D8F";
			data.end_date.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(data.title.value == "" || data.title.value.charAt(0) == " "){
			data.title.style.background = "#f37474";
			data.title.style.color = "#fff";
			data.title.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			data.title.style.background = "#ffffff";
			data.title.style.color = "#888D8F";
			data.title.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function questionsUploadValidation(){
	var error = 0;
	
	var fup = document.getElementById('csv_file');
	var fileName = fup.value;
	
	if(document.questionsupload.uid.value == 0){
			document.questionsupload.uid.style.background = "#f37474";
			document.questionsupload.uid.style.color = "#fff";
			document.questionsupload.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.questionsupload.uid.style.background = "#ffffff";
			document.questionsupload.uid.style.color = "#888D8F";
			document.questionsupload.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.questionsupload.csv_file.value == "" || document.questionsupload.csv_file.value.substring(fileName.lastIndexOf('.') + 1) != "csv"){
			document.questionsupload.csv_file.style.background = "#f37474";
			document.questionsupload.csv_file.style.color = "#fff";
			document.questionsupload.csv_file.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			alert("Please select a csv extension file. Use Excel to export");
			error += 1;
	} else {
			document.questionsupload.csv_file.style.background = "#ffffff";
			document.questionsupload.csv_file.style.color = "#888D8F";
			document.questionsupload.csv_file.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function optionalQuestionsValidation(){
	var error = 0;

	if(document.optional.uid.value == 0){
			document.optional.uid.style.background = "#f37474";
			document.optional.uid.style.color = "#fff";
			document.optional.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.optional.uid.style.background = "#ffffff";
			document.optional.uid.style.color = "#888D8F";
			document.optional.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.optional.question.value == "" || document.optional.question.value.charAt(0) == " "){
			document.optional.question.style.background = "#f37474";
			document.optional.question.style.color = "#fff";
			document.optional.question.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.optional.question.style.background = "#ffffff";
			document.optional.question.style.color = "#888D8F";
			document.optional.question.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.optional.answer.value == "" || document.optional.answer.value.charAt(0) == " "){
			document.optional.answer.style.background = "#f37474";
			document.optional.answer.style.color = "#fff";
			document.optional.answer.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.optional.answer.style.background = "#ffffff";
			document.optional.answer.style.color = "#888D8F";
			document.optional.answer.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.optional.false_answera.value == "" || document.optional.false_answera.value.charAt(0) == " "){
			document.optional.false_answera.style.background = "#f37474";
			document.optional.false_answera.style.color = "#fff";
			document.optional.false_answera.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.optional.false_answera.style.background = "#ffffff";
			document.optional.false_answera.style.color = "#888D8F";
			document.optional.false_answera.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.optional.false_answerb.value == "" || document.optional.false_answerb.value.charAt(0) == " "){
			document.optional.false_answerb.style.background = "#f37474";
			document.optional.false_answerb.style.color = "#fff";
			document.optional.false_answerb.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.optional.false_answerb.style.background = "#ffffff";
			document.optional.false_answerb.style.color = "#888D8F";
			document.optional.false_answerb.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.optional.false_answerc.value == "" || document.optional.false_answerc.value.charAt(0) == " "){
			document.optional.false_answerc.style.background = "#f37474";
			document.optional.false_answerc.style.color = "#fff";
			document.optional.false_answerc.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.optional.false_answerc.style.background = "#ffffff";
			document.optional.false_answerc.style.color = "#888D8F";
			document.optional.false_answerc.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function openQuestionsValidation(){
	var error = 0;

	if(document.openquestion.uid.value == 0){
			document.openquestion.uid.style.background = "#f37474";
			document.openquestion.uid.style.color = "#fff";
			document.openquestion.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.openquestion.uid.style.background = "#ffffff";
			document.openquestion.uid.style.color = "#888D8F";
			document.openquestion.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.openquestion.questiona.value == "" || document.openquestion.questiona.value.charAt(0) == " "){
			document.openquestion.questiona.style.background = "#f37474";
			document.openquestion.questiona.style.color = "#fff";
			document.openquestion.questiona.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.openquestion.questiona.style.background = "#ffffff";
			document.openquestion.questiona.style.color = "#888D8F";
			document.openquestion.questiona.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function multipleQuestionsValidation(){
	var error = 0;

	if(document.multiple.uid.value == 0){
			document.multiple.uid.style.background = "#f37474";
			document.multiple.uid.style.color = "#fff";
			document.multiple.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.multiple.uid.style.background = "#ffffff";
			document.multiple.uid.style.color = "#888D8F";
			document.multiple.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.multiple.question.value == "" || document.multiple.question.value.charAt(0) == " "){
			document.multiple.question.style.background = "#f37474";
			document.multiple.question.style.color = "#fff";
			document.multiple.question.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.multiple.question.style.background = "#ffffff";
			document.multiple.question.style.color = "#888D8F";
			document.multiple.question.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.multiple.answera.value == "" || document.multiple.answera.value.charAt(0) == " "){
			document.multiple.answera.style.background = "#f37474";
			document.multiple.answera.style.color = "#fff";
			document.multiple.answera.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.multiple.answera.style.background = "#ffffff";
			document.multiple.answera.style.color = "#888D8F";
			document.multiple.answera.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.multiple.falsea.value == "" || document.multiple.falsea.value.charAt(0) == " "){
			document.multiple.falsea.style.background = "#f37474";
			document.multiple.falsea.style.color = "#fff";
			document.multiple.falsea.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.multiple.falsea.style.background = "#ffffff";
			document.multiple.falsea.style.color = "#888D8F";
			document.multiple.falsea.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function matchQuestionsValidation(){
	var error = 0;

	if(document.matchquestion.uid.value == 0){
			document.matchquestion.uid.style.background = "#f37474";
			document.matchquestion.uid.style.color = "#fff";
			document.matchquestion.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.matchquestion.uid.style.background = "#ffffff";
			document.matchquestion.uid.style.color = "#888D8F";
			document.matchquestion.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.matchquestion.questiona.value == "" || document.matchquestion.questiona.value.charAt(0) == " "){
			document.matchquestion.questiona.style.background = "#f37474";
			document.matchquestion.questiona.style.color = "#fff";
			document.matchquestion.questiona.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.matchquestion.questiona.style.background = "#ffffff";
			document.matchquestion.questiona.style.color = "#888D8F";
			document.matchquestion.questiona.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.matchquestion.answera.value == "" || document.matchquestion.answera.value.charAt(0) == " "){
			document.matchquestion.answera.style.background = "#f37474";
			document.matchquestion.answera.style.color = "#fff";
			document.matchquestion.answera.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.matchquestion.answera.style.background = "#ffffff";
			document.matchquestion.answera.style.color = "#888D8F";
			document.matchquestion.answera.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function essaysQuestionsValidation(){
	var error = 0;

	if(document.essays.uid.value == 0){
			document.essays.uid.style.background = "#f37474";
			document.essays.uid.style.color = "#fff";
			document.essays.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.essays.uid.style.background = "#ffffff";
			document.essays.uid.style.color = "#888D8F";
			document.essays.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.essays.questiona.value == "" || document.essays.questiona.value.charAt(0) == " "){
			document.essays.questiona.style.background = "#f37474";
			document.essays.questiona.style.color = "#fff";
			document.essays.questiona.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.essays.questiona.style.background = "#ffffff";
			document.essays.questiona.style.color = "#888D8F";
			document.essays.questiona.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function problemsQuestionsValidation(){
	var error = 0;

	if(document.problems.uid.value == 0){
			document.problems.uid.style.background = "#f37474";
			document.problems.uid.style.color = "#fff";
			document.problems.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.problems.uid.style.background = "#ffffff";
			document.problems.uid.style.color = "#888D8F";
			document.problems.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.problems.questiona.value == "" || document.problems.questiona.value.charAt(0) == " "){
			document.problems.questiona.style.background = "#f37474";
			document.problems.questiona.style.color = "#fff";
			document.problems.questiona.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.problems.questiona.style.background = "#ffffff";
			document.problems.questiona.style.color = "#888D8F";
			document.problems.questiona.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function truefalseQuestionsValidation(){
	var error = 0;

	if(document.truefalse.uid.value == 0){
			document.truefalse.uid.style.background = "#f37474";
			document.truefalse.uid.style.color = "#fff";
			document.truefalse.uid.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.truefalse.uid.style.background = "#ffffff";
			document.truefalse.uid.style.color = "#888D8F";
			document.truefalse.uid.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.truefalse.questiona.value == "" || document.truefalse.questiona.value.charAt(0) == " "){
			document.truefalse.questiona.style.background = "#f37474";
			document.truefalse.questiona.style.color = "#fff";
			document.truefalse.questiona.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.truefalse.questiona.style.background = "#ffffff";
			document.truefalse.questiona.style.color = "#888D8F";
			document.truefalse.questiona.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.truefalse.answera.value == "" || document.truefalse.answera.value.charAt(0) == " "){
			document.truefalse.answera.style.background = "#f37474";
			document.truefalse.answera.style.color = "#fff";
			document.truefalse.answera.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
			error += 1;
	} else {
			document.truefalse.answera.style.background = "#ffffff";
			document.truefalse.answera.style.color = "#888D8F";
			document.truefalse.answera.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}

	if(error != 0){
			return false;
	} else {
			return true;
	}
}

function take_exam(uid){
	document.take_test.exam_id.value = uid;
	document.take_test.submit();
}

function add_questions(){
	var error = 0;
	
	if(document.setupexam.questions_type.value == 0){
		document.setupexam.questions_type.style.background = "#f37474";
		document.setupexam.questions_type.style.color = "#fff";
		document.setupexam.questions_type.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.setupexam.questions_type.style.background = "#ffffff";
		document.setupexam.questions_type.style.color = "#888D8F";
		document.setupexam.questions_type.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.setupexam.questions_quantity.value == 0){
		document.setupexam.questions_quantity.style.background = "#f37474";
		document.setupexam.questions_quantity.style.color = "#fff";
		document.setupexam.questions_quantity.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.setupexam.questions_quantity.style.background = "#ffffff";
		document.setupexam.questions_quantity.style.color = "#888D8F";
		document.setupexam.questions_quantity.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(error != 0){
		return false;
	}
	
	var current_type = document.setupexam.question_type.value;
	var current_quantity = document.setupexam.question_quantity.value;
	
	if(current_type == 0 && current_quantity == 0){
		document.setupexam.question_type.value = document.setupexam.questions_type.value;
		document.setupexam.question_quantity.value = document.setupexam.questions_quantity.value;
	} else {
		document.setupexam.question_type.value = document.setupexam.question_type.value + "," + document.setupexam.questions_type.value;
		document.setupexam.question_quantity.value = document.setupexam.question_quantity.value + "," + document.setupexam.questions_quantity.value;
	}
	
	if(current_type == 0 || current_quantity == 0){
		document.getElementById('questions_status').innerHTML = "Added " + document.setupexam.questions_quantity.value + " " + document.setupexam.questions_type.value + " questions <a href='#' onclick=\"javascript:remove_questions('" + document.setupexam.questions_type.value + "','" + document.setupexam.questions_quantity.value + "');\"><img src='../images/delete-icon.png' width='18' height='18' alt='delete' border='0' align='texttop' /></a>";
	} else {
		document.getElementById('questions_status').innerHTML = document.getElementById('questions_status').innerHTML + ", added " + document.setupexam.questions_quantity.value + " " + document.setupexam.questions_type.value + " questions <a href='#' onclick=\"javascript:remove_questions('" + document.setupexam.questions_type.value + "','" + document.setupexam.questions_quantity.value + "');\"><img src='../images/delete-icon.png' width='18' height='18' alt='delete' border='0' align='texttop' /></a>";
	}
	
	//Reset the dropdown menus
	document.setupexam.questions_type.value = 0;
	document.setupexam.questions_quantity.value = 0;
}

function remove_questions(questions_type, questions_quantity){
	alert(questions_type + ", " + questions_quantity);
	var current_type = document.setupexam.question_type.value;
	var current_quantity = document.setupexam.question_quantity.value;
	var current_type_array = current_type.split(",");
	var current_quantity_array = current_quantity.split(",");
	alert(current_type_array);
	alert(current_quantity_array);
	var new_type = "";
	var new_quantity = "";
	var already_removed = 0;
	document.getElementById('questions_status').innerHTML = "";
	for(var i in current_type_array){
		if(current_type_array[i] != questions_type && current_quantity_array[i] != questions_quantity || already_removed == 1){
			if(new_type == ""){
				new_type = current_type_array[i];
				new_quantity = current_quantity_array[i];
				document.getElementById('questions_status').innerHTML = "Added " + current_quantity_array[i] + " " + current_type_array[i] + " questions <a href='#' onclick=\"javascript:remove_questions('" + current_type_array[i] + "','" + current_quantity_array[i] + "');\"><img src='../images/delete-icon.png' width='18' height='18' alt='delete' border='0' align='texttop' /></a>";
			} else {
				new_type = new_type + "," + current_type_array[i];
				new_quantity = new_quantity  + "," + current_quantity_array[i];
				document.getElementById('questions_status').innerHTML = document.getElementById('questions_status').innerHTML + ", added " + current_quantity_array[i] + " " + current_type_array[i] + " questions <a href='#' onclick=\"javascript:remove_questions('" + current_type_array[i] + "','" + current_quantity_array[i] + "');\"><img src='../images/delete-icon.png' width='18' height='18' alt='delete' border='0' align='texttop' /></a>";
			}
		} else {
			already_removed = 1;
		}
	}
	if(new_type == ""){
		new_type = 0;
		new_quantity = 0;
		document.getElementById('questions_status').innerHTML = "Select your question type and question quantity from the dropdowns above and then click \"Add this configuration\" link to apply that settings. The selected settings will appear in this part, you can add up to 7 different questions type.";
	}
	document.setupexam.question_type.value = new_type;
	document.setupexam.question_quantity.value = new_quantity;
}

function testing(data){
	var newvalue = document.getElementById(data).value;
	alert( "Value " + newvalue + " ID: " + data);
}